<?php 
header("Access-Control-Allow-Origin:*");
	// 获取get请求中的用户名
	$username = $_POST["username"];
	$password = $_POST["password"];

	/* 连接数据，验证 */
	$conn = mysqli_connect("localhost", "root", "root", "mi");
	// SQL
	$sql = "SELECT * FROM users WHERE username='$username'";
	// 执行查询
	$result = mysqli_query($conn, $sql);
	// 判断
	// if ($row = mysqli_fetch_assoc($result)) { // 存在用户
	if (mysqli_num_rows($result) >= 1) {
		$arr = array("res_code"=>-1, "res_message"=>"exist");
		echo json_encode($arr);
	} else { // 不存在用户
		$sql1 = "INSERT  INTO `users`(`username`,`password`) VALUES('$username','$password')" ;
		mysqli_query($conn, $sql1);
		$arr = array("res_code"=>1, "res_message"=>"not exist");
		echo json_encode($arr);
	}
	// 关闭
	mysqli_close($conn)
 ?>